from django.db import models

# Create your models here.
from utils.models import BaseModel


class Movie(models.Model):
    MOVIE_STATUS_CHOICES = (
        (1, '正在热映'),
        (2, '即将上映'),
        (3, '经典影片'),
    )
    name = models.CharField(max_length=50, verbose_name='电影名称')
    en_name = models.CharField(max_length=50, verbose_name='电影英文名称')
    area = models.CharField(max_length=50, null=True, verbose_name='拍摄电影地区')
    time = models.CharField(max_length=10, default=None, null=True, verbose_name='电影时长')
    show_time_area = models.CharField(max_length=500, null=True, verbose_name='上映的地区及时间')
    # show_area = models.CharField(max_length=50, verbose_name='上映地区')
    introduction = models.CharField(max_length=2000, verbose_name='剧情介绍')
    start = models.FloatField(null=True, default=0, verbose_name='猫眼口碑')
    comment_peoples = models.IntegerField(null=True, default=0, verbose_name='评分人数')
    box_office_count = models.IntegerField(null=True, default=0, verbose_name='累计票房')
    want_see = models.IntegerField(null=True, default=0, verbose_name='想看人数')

    movie_status = models.SmallIntegerField(choices=MOVIE_STATUS_CHOICES, null=True, verbose_name='电影状态')

    class Meta:
        db_table = 'tb_movie'
        verbose_name = '电影信息'
        verbose_name_plural = verbose_name


class MovieTags(models.Model):
    value = models.CharField(max_length=10, verbose_name='电影标签')
    movie = models.ForeignKey(Movie, on_delete=models.CASCADE, related_name='tags', verbose_name='标签关联的电影')

    class Meta:
        db_table = 'tb_movie_tags'
        verbose_name = '电影标签'
        verbose_name_plural = verbose_name


class Stardom(models.Model):
    name = models.CharField(max_length=50, verbose_name='演员名字')
    portray = models.CharField(max_length=200, verbose_name='饰演角色')
    movie = models.ForeignKey(Movie, on_delete=models.CASCADE, related_name='stardom', verbose_name='演员所演的电影')

    class Meta:
        db_table = 'tb_stardom'
        verbose_name = '演员表'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
